package com.api.invitation.sendinvitation;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.test.context.ContextConfiguration;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;

import com.api.test.AbstractApiTest;
import com.zyncro.api.IInvitationApiService;
import com.zyncro.api.exceptions.UserNoPermissionApiException;
import com.zyncro.api.exceptions.ZyncroApiException;

@ContextConfiguration(locations = { "classpath:/invitation/invitation-context.xml" })
public class SendInvitationNotInviter extends AbstractApiTest {

	@Value("#{group_toInvite[notInviter].appId}")
	private String userId;

	@Value("#{group_toInvite[notInviter].password}")
	private String userPassword;

	@Value("#{group_toInvite.urn}")
	private String groupUrn;

	@Value("#{user_toInvite.appId}")
	private String userToInvite;

	@BeforeClass
	public void setUpVariables() {

		getApi().login(userId, userPassword);
	}

	@SuppressWarnings("deprecation")
	@Test(expectedExceptions = UserNoPermissionApiException.class)
	public synchronized void testSendInvitation() throws ZyncroApiException {

		String enableEditor = "false";
		String enableInviter = "false";
		String enableTaskManager = "false";
		String comment = "comentario";
		String isOwner = "false";

		getApi().getService(IInvitationApiService.class).sendInvitation(userToInvite, groupUrn, enableEditor, enableInviter, enableTaskManager,
				comment, isOwner);
	}
}
